// vue3.0中createRouter来创建路由实例，
// createWebHashHistory代表使用hash模式的路由。

import { createRouter, createWebHashHistory } from 'vue-router'

const Layout = () => import('@/views/layout')
const Home = () => import('@/views/home')
const Login = () => import('@/views/login')
const TopCategory = () => import('@/views/category')
const SubCategory = () => import('@/views/category/sub')
// 配置路由规则
const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      { path: '/', component: Home },
      { path: '/category/:id', component: TopCategory },
      { path: '/category/sub/:id', component: SubCategory }
    ]
  },
  { path: '/login', component: Login }
]

// 创建路由实例
const router = createRouter({
  // 使用hash方式实现路由
  history: createWebHashHistory(),
  // 配置路由规则
  routes
})

// 导出路由实例
export default router
